package com.yizhuoyan.his.servicesupport.impl;

import com.yizhuoyan.his.algorithm.SnowFlake64Id;
import com.yizhuoyan.his.servicesupport.DatabaseIdGenerateSupportService;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class DatabaseIdGenerateSupportServiceImpl implements DatabaseIdGenerateSupportService {
    final private SnowFlake64Id snowFlake64Id;

    public DatabaseIdGenerateSupportServiceImpl(Environment env) {
        int workerId=env.getProperty("snowflake.workerId",Integer.class,1);
        this.snowFlake64Id =new SnowFlake64Id(workerId);
    }

    @Override
    public long nextId() {
        return snowFlake64Id.nextId();
    }
}
